services:
  agent:
    command: sh -c 'bin/wait && python -m deeppavlov_agent.run agent.pipeline_config=assistant_dists/dream_russian_persona_based/pipeline_conf.json'
    environment:
      WAIT_HOSTS: "convers-evaluation-selector-ru:8009, 
          dff-intent-responder-ru-skill:8012, intent-catcher-ru:8014, badlisted-words-ru:8018,
          sentseg-ru:8011, dff-generative-ru-skill:8092, dialogpt-ru:8125,
          dialogrpt-ru:8122, combined-classification-ru:8198,
          relative-persona-extractor-ru:8133, seq2seq-persona-based-ru:8140"
      WAIT_HOSTS_TIMEOUT: ${WAIT_TIMEOUT:-1200}
      HIGH_PRIORITY_INTENTS: 1
      RESTRICTION_FOR_SENSITIVE_CASE: 1
      ALWAYS_TURN_ON_ALL_SKILLS: 0
      LANGUAGE: RU
      FALLBACK_FILE: fallbacks_dream_ru.json

  dff-program-y-ru-skill:
    env_file: [ .env_ru ]
    build:
      args:
        SERVICE_PORT: 8008
        SERVICE_NAME: dff_program_y_skill
        LANGUAGE: RU
      context: .
      dockerfile: ./skills/dff_program_y_skill/Dockerfile
    command: gunicorn --workers=1 server:app -b 0.0.0.0:8008 --reload
    deploy:
      resources:
        limits:
          memory: 1024M
        reservations:
          memory: 1024M

  convers-evaluation-selector-ru:
    env_file: [ .env_ru ]
    build:
      args:
        TAG_BASED_SELECTION: 1
        CALL_BY_NAME_PROBABILITY: 0.5
        PROMPT_PROBA: 0.1
        ACKNOWLEDGEMENT_PROBA: 0.3
        PRIORITIZE_WITH_REQUIRED_ACT: 0
        PRIORITIZE_NO_DIALOG_BREAKDOWN: 0
        PRIORITIZE_WITH_SAME_TOPIC_ENTITY: 0
        IGNORE_DISLIKED_SKILLS: 0
        GREETING_FIRST: 1
        RESTRICTION_FOR_SENSITIVE_CASE: 1
        PRIORITIZE_PROMTS_WHEN_NO_SCRIPTS: 1
        MAX_TURNS_WITHOUT_SCRIPTS: 7
        ADD_ACKNOWLEDGMENTS_IF_POSSIBLE: 1
        PRIORITIZE_SCRIPTED_SKILLS: 0
        CONFIDENCE_STRENGTH: 0.8
        CONV_EVAL_STRENGTH: 0.4
        PRIORITIZE_HUMAN_INITIATIVE: 1
        QUESTION_TO_QUESTION_DOWNSCORE_COEF: 0.8
        LANGUAGE: RU
        FALLBACK_FILE: fallbacks_dream_ru.json
      context: .
      dockerfile: ./response_selectors/convers_evaluation_based_selector/Dockerfile
    command: flask run -h 0.0.0.0 -p 8009
    environment:
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 256M
        reservations:
          memory: 256M

  dff-intent-responder-ru-skill:
    env_file: [ .env_ru ]
    build:
      args:
        SERVICE_PORT: 8012
        SERVICE_NAME: dff_intent_responder_skill
        INTENT_RESPONSE_PHRASES_FNAME: intent_response_phrases_RU.json
        LANGUAGE: RU
      context: .
      dockerfile: ./skills/dff_intent_responder_skill/Dockerfile
    command: gunicorn --workers=1 server:app -b 0.0.0.0:8012 --reload
    deploy:
      resources:
        limits:
          memory: 128M
        reservations:
          memory: 128M

  sentseg-ru:
    env_file: [ .env_ru ]
    build:
      args:
        CONFIG: sentseg_ru_bert_torch.json
      context: ./annotators/sentseg_ru
      dockerfile: Dockerfile-test
    command: flask run -h 0.0.0.0 -p 8011
    environment:
      - CUDA_VISIBLE_DEVICES=0
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 3G
        reservations:
          memory: 3G

  intent-catcher-ru:
    env_file: [ .env_ru ]
    build:
      context: .
      dockerfile: ./annotators/IntentCatcherTransformers/Dockerfile
      args:
        SERVICE_PORT: 8014
        CONFIG_NAME: intents_model_dp_config_RU.json
        INTENT_PHRASES_PATH: intent_phrases_RU.json
    command: python -m flask run -h 0.0.0.0 -p 8014
    environment:
      - FLASK_APP=server
      - CUDA_VISIBLE_DEVICES=0
    deploy:
      resources:
        limits:
          memory: 3.5G
        reservations:
          memory: 3.5G

  badlisted-words-ru:
    env_file: [ .env_ru ]
    build:
      args:
        SERVICE_PORT: 8018
        SERVICE_NAME: badlisted_words
      context: annotators/BadlistedWordsDetector_ru/
    command: flask run -h 0.0.0.0 -p 8018
    environment:
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 128M
        reservations:
          memory: 128M

  combined-classification-ru:
    env_file: [ .env_ru ]
    build:
      args:
        SERVICE_PORT: 8198
        SERVICE_NAME: combined_classification_ru
        CONFIG: combined_classifier_ru.json
      context: .
      dockerfile: ./annotators/combined_classification_ru/Dockerfile
    command: gunicorn --workers=1 server:app -b 0.0.0.0:8198 --timeout 600
    environment:
      - CUDA_VISIBLE_DEVICES=0
    deploy:
      resources:
        limits:
          memory: 2G
        reservations:
          memory: 2G

  dialogpt-ru:
    env_file: [ .env_ru ]
    build:
      context: ./services/dialogpt_RU/
      args:
        SERVICE_PORT: 8125
        PRETRAINED_MODEL_NAME_OR_PATH: DeepPavlov/rudialogpt3_medium_based_on_gpt2_v2
        LANGUAGE: RU
        MAX_HISTORY_DEPTH: 3
    command: flask run -h 0.0.0.0 -p 8125
    environment:
      - CUDA_VISIBLE_DEVICES=0
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 3G
        reservations:
          memory: 3G

  dff-generative-ru-skill:
    env_file: [ .env_ru ]
    build:
      args:
        SERVICE_PORT: 8092
        SERVICE_NAME: dff_generative_skill
        LANGUAGE: RU
        GENERATIVE_SERVICE_URL: http://dialogpt-ru:8125/respond
      context: .
      dockerfile: ./skills/dff_generative_skill/Dockerfile
    command: gunicorn --workers=1 server:app -b 0.0.0.0:8092 --reload
    deploy:
      resources:
        limits:
          memory: 128M
        reservations:
          memory: 128M

  dialogrpt-ru:
    env_file: [ .env_ru ]
    build:
      context: ./services/dialogrpt_ru/
      args:
        SERVICE_PORT: 8122
        PRETRAINED_MODEL_FNAME: dialogrpt_ru_ckpt_v0.pth
        TOKENIZER_NAME_OR_PATH: DeepPavlov/rudialogpt3_medium_based_on_gpt2_v2
    command: flask run -h 0.0.0.0 -p 8122
    environment:
      - CUDA_VISIBLE_DEVICES=0
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 4G
        reservations:
          memory: 4G

  seq2seq-persona-based-ru:
    env_file: [ .env_ru ]
    build:
      args:
        SERVICE_PORT: 8140
        SERVICE_NAME: seq2seq_persona_based
        PRETRAINED_MODEL_NAME_OR_PATH: DeepPavlov/mbart-large-50-ru-persona-chat
        PAIR_DIALOG_HISTORY_LENGTH: 2
        CHAT_EVERY_SENT_MAX_LENGTH: 25
        PERSONA_EVERY_SENT_MAX_LENGTH: 19
        GENERATION_PARAMS_CONFIG: bart-large-ru-persona-chat_v1.json
      context: .
      dockerfile: ./services/seq2seq_persona_based/Dockerfile
    command: flask run -h 0.0.0.0 -p 8140
    environment:
      - CUDA_VISIBLE_DEVICES=0
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 2G
        reservations:
          memory: 2G

  relative-persona-extractor-ru:
    env_file: [ .env_ru ]
    build:
      args:
        SERVICE_PORT: 8133
        SERVICE_NAME: relative_persona_extractor
        SENTENCE_RANKER_SERVICE_URL: http://dialogrpt-ru:8122/respond
        N_SENTENCES_TO_RETURN: 3
      context: .
      dockerfile: ./annotators/relative_persona_extractor/Dockerfile
    command: flask run -h 0.0.0.0 -p 8133
    environment:
      - FLASK_APP=server
    deploy:
      resources:
        limits:
          memory: 100M
        reservations:
          memory: 100M

version: '3.7'
